﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SoccerSimulator5000
{
    public partial class NewGameForm : Form
    {
        
        public NewGameForm(  )
        {
            InitializeComponent();
            this.CenterToParent();
        }

        private void buttonStartGame_Click(object sender, EventArgs e)
        {
            Team playerTeam = new Team();
            int teamNumber = 11;

            foreach(var item in this.Controls)
            {
                if (item.GetType() == radioButtonTeam1.GetType())
                {
                    
                    if (((RadioButton)item).Checked)
                    {
                        playerTeam = Game.teamList[teamNumber];
                    }
                    teamNumber--;
                }
            }
           
            if (this.textBoxTeamName.Text != "")
            {
                playerTeam.name = this.textBoxTeamName.Text;
            }

            if (Game.initialized)
            {
                Game.season.Clear();
                foreach (var Team in Game.teamList)
                {
                    Team.standingsData = new StandingsData();
                }
            }

            Game.player.name = textBoxPlayerName.Text;
            Game.player.playerTeam = playerTeam;
            Game.initialized = true;
            Game.date = new Date();
            Game.season.seasonFixtures.GenerateFixtures();
            

            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }





    }
}
